Socket
Socket
Sign inDemoInstall

react-proxy

Package Overview
Dependencies
1
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-proxy

Proxies React components without unmounting or losing their state.


Version published
Weekly downloads
166K
decreased by-4.32%
Maintainers
1
Install size
899 kB
Created
Weekly downloads
 

Readme

Source

React Proxy build status npm version

Work in progress.

Generic React component proxy.
A future engine for React Hot Loader.

Requirements

  • React 0.13+

Usage

Intended to be used from hot reloading tools like React Hot Loader.
If you’re an application developer, it’s unlikely you’ll want to use it directly.

import React, { Component } from 'react';

class ComponentVersion1 extends Component {
  render() {
    return <div>Before hot update.</div>;
  }
}

class ComponentVersion2 extends Component {
  render() {
    return <div>After hot update.</div>;
  }
}

Without React Proxy:

const rootEl = document.getElementById('root');
React.render(<ComponentVersion1 />, rootEl);
React.render(<ComponentVersion2 />, rootEl); // will reset state and kill DOM :-(

With React Proxy:

import { createProxy, getForceUpdate } from 'react-proxy';

const proxy = createProxy(ComponentVersion1);

const Proxy = proxy.get();
React.render(<Proxy />, rootEl);

// will update the mounted instances' prototypes:
// both DOM and state are perserved.
const mountedInstances = proxy.update(ComponentVersion2);

// works with React Native and non-Component descendants
const forceUpdate = getForceUpdate(React);
mountedInstances.forEach(forceUpdate);

License

MIT

FAQs

Last updated on 27 Aug 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc